package cn.itcast.tlias.com.tliaswork.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Slf4j
@Component
//@Aspect
public class MyAspect1 {

    //抽取切入点方法
    @Pointcut("execution(* cn.itcast.tlias.com.tliaswork.service.impl.DeptServiceImpl.*(..))")
    public void pt(){}

    //抽取前
    @Before("execution(* cn.itcast.tlias.com.tliaswork.service.impl.DeptServiceImpl.*(..))")
    public void before() {
        log.info("before....");

    }
    //抽取后
    @Around("pt()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {

        log.info("around before....");
        //调用目标对象的原始方法执行
        Object proceed = joinPoint.proceed();
        log.info("around after....");

        return proceed;
    }

    @After("pt()")
    public void after(){
        log.info("after ....");
    }

    @AfterReturning("pt()")
    public void afterReturning(){
        log.info("afterReturning ....");
    }

    @AfterThrowing("pt()")
    public void afterThrowing(){
        log.info("afterThrowing ....");
    }
}
